<?php

$this->useClass('RL_Utils_Style');
class RL_Meta
{

	/**
	 * object объект, к которому привязана эта мета
	 *
	 * @var mixed
	 * @access public
	 */
	public $object = NULL;

	public function __construct ($ctx)
	{
		$this->ctx = $ctx;
	} // end of __construct

	public function __call ($name, $args)
	{
		if (substr($name, 0, 3) == 'get') {
			return $this->get(substr($name, 3));
		}
		if (substr($name, 0, 3) == 'set') {
			return $this->set(substr($name, 3), $args[0]);
		}
	} // end of function __call

	public function get ($name)
	{
		$prop = RL_Utils_Style::unixStyle($name);
		if (isset($this->$prop)) return $this->$prop;
		return NULL;
	} // end of function get
	public function set ($name, $value)
	{
		$prop = RL_Utils_Style::unixStyle($name);
		$this->$prop = $value;
		return $this;
	} // end of function get

	public function setObject ($value)
	{
		$this->object= $value;
		return $this;
	} // end of function setObject

	public function getObject ()
	{
		return $this->object;
	} // end of function getObject
	//!a constructor
	/**
	 * create создать мету
	 *
	 * @param mixed $type тип
	 * @access public
	 * @return RL_Meta
	 */
	static public function create ($ctx, $type)
	{
		$cls = __CLASS__ . '_' . $type;
		$ctx->rh->useClass($cls);
		$meta = new $cls($ctx);
		$meta->setName($type);
		return $meta;
	} // end of function create
}

